package com.hugh.commom.selector;

import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * @Author: Hugh
 * @Date: 2020/6/23
 */
@Builder
public class ChannelFutureEntity implements Serializable {

    /**
     * channel
     */
    private ChannelFuture channelFuture;
    /**
     * bootstrap
     */
    private Bootstrap bootstrap;
    /**
     * channel的具体的ip和端口
     */
    private String ip;

    /**
     * channel的具体的ip和端口
     */
    private Integer port;

    /**
     * channel记录上一次的响应时间
     */
    private Long rt;

    /**
     * channel的对应的方法名
     */
    private String service;


    public ChannelFuture getChannelFuture() {
        return channelFuture;
    }

    public void setChannelFuture(ChannelFuture channelFuture) {
        this.channelFuture = channelFuture;
    }

    public Bootstrap getBootstrap() {
        return bootstrap;
    }

    public void setBootstrap(Bootstrap bootstrap) {
        this.bootstrap = bootstrap;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public Long getRt() {
        return rt;
    }

    public void setRt(Long rt) {
        //关闭上一次的链接
        if(Objects.nonNull(channelFuture)){
            channelFuture.channel().close();
        }
        if(rt > 0L){

        }
        this.rt = rt;
    }

    public String getService() {
        return service;
    }

    public void setService(String service) {
        this.service = service;
    }


}
